from __future__ import print_function
import tensorflow as tf
import numpy as np
from pandas import Series, DataFrame
import pandas as pd

df = pd.read_csv("../data/m5/sz131810.csv", header=None, parse_dates=['time'],
                 names=['time', 'open', 'close', 'high', 'low', 'vol'],
                 skip_blank_lines=True)
# print(df)
print(df.mean())
sLength = len(df['time'])
e = Series(np.random.random_integers(0, high=sLength))
f = Series(np.random.random_integers(0, high=sLength))
df['index'] = e
df['weekday'] = f
# vol = df['high']/df.mean()['vol']
# print(df['time'][48*6-1])
last_weekday = 0
index = 0
for i in range(df['time'].size):
    dtime = df['time'][i]
    weekday = dtime.isoweekday()
    if weekday == last_weekday:
        index += 1
        df.loc[i, 'index'] = index
    else:
        last_weekday = weekday
        index = 0
    df.loc[i, 'index'] = index
    df.loc[i, 'weekday'] = weekday

# print(df['index', 'weekday', 'open', 'close', 'high', 'low'])
print(df[['index', 'weekday']])
# file006 = open('../DATA/m15/sz399006.csv')
# index = 0
# open_array = []
# for line in file006:
#     index += 1
#     # print(index, ' ', line)
#     data = line.split(',')
#     open_array.append((float)(data[1]))
#     print(data[0])
# print(open_array)
# print(np.mean(np.array(open_array)))
# file006.close()

# print("hello world")
# hello = tf.constant_initializer("hello world")
#
# pl = tf.placeholder(tf.int32, [None, 1])
# name = tf.Variable(tf.zeros([1,1]))
#
# init = tf.global_variables_initializer()
# with tf.Session() as sess:
#     sess.run(init)
#     data = np.arange(0,10).reshape([10,1])
#     print(data)
#     my = sess.run(name, feed_dict={pl: data})
#     print(tf.value())
